use crate::types::Type;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;

#[derive(Debug, Default)]
pub struct HeapCell {
    static_fields: HashMap<String, Type>,
}

#[derive(Clone, Debug, Default)]
pub struct Heap {
    pub(crate) cell: Rc<RefCell<HeapCell>>,
}

impl Heap {
    pub fn get_static(&mut self, name: String) -> Type {
        (*self.cell).borrow().static_fields[&name]
    }

    pub fn put_static(&mut self, name: String, value: Type) {
        (*self.cell).borrow_mut().static_fields.insert(name, value);
    }
}
